import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yp/router.dart';

import 'view.dart';

class MyState {
  RefreshController controller1 = RefreshController();
  var userInformationData; // 用户信息
  dynamic availableCouponsNum = 0; // 优惠券数量
  dynamic userIntegralNum = 0; // 积分
  dynamic walletNum = 0; // 钱包
  // gyq add
  String unPayCount = ''; //未付款订单数量
  String arrivedCount = ''; //待提货订单数量
  String notSendCount = ''; //未发货订单数量
  String unCommentCount = ''; //未评价订单数量
  String serviceCount = ''; //售后服务订单数量
  var diyConfigData; //用户中心自定义配置
  List<MyTaskModel> taskData = []; //做任务得奖励
  List goodList = []; //推荐商品
  String keFuString = ''; // 客服信息
  List pingJiaList = []; // 评价有礼
}

class MyTaskModel {
  int id;
  String icon;
  String name;
  String actionText;
  MyTaskModel({this.id, this.icon, this.name, this.actionText});
}

class MyInfoConfig {
  //渐变色
  String backgroundColor = '#000000,#C19000';
  Color toolTextColor = HexColor.fromHex('#FFD278');
  Color toolColor = HexColor.fromHex('#000000');
  String defaultAvater = '';

  //会员商城 配置
  var mem_card_image = '';
  var mem_icon = '';
  Color mem_title_color = HexColor.fromHex('#231815');
  var mem_button_value =
      '#7E4303,#582E02'.split(',').map((e) => HexColor.fromHex(e)).toList();
  var mem_button_text_color = HexColor.fromHex('#FFFFFF');

  List<String> walletSigns = ['1,2,3'];
  // List<String> walletSigns = ['1,2'];

  MyInfoConfig(data) {
    if (data == null) {
      return;
    }
    var infoConfig = data['personal_config_mem_center']['mem_info_config'];
    backgroundColor = infoConfig['background_value'];
    toolTextColor = HexColor.fromHex(infoConfig['tool_text_color']);
    toolColor = HexColor.fromHex(infoConfig['tool_color']);
    defaultAvater = infoConfig['default_image'];

    var memConfig = infoConfig['mem_grade_info_config'];
    if (memConfig != null) {
      mem_card_image = memConfig['mem_card_image'] ?? '';
      mem_icon = memConfig['mem_icon'];
      mem_title_color = HexColor.fromHex(memConfig['title_color']);
      String buttonValue = memConfig['button_value'];
      if (buttonValue.contains(',')) {
        mem_button_value =
            buttonValue.split(',').map((e) => HexColor.fromHex(e)).toList();
      } else if (buttonValue.length > 0) {
        mem_button_value =
            List.generate(2, (index) => HexColor.fromHex(buttonValue));
      }
      mem_button_text_color = HexColor.fromHex(memConfig['button_text_color']);
    }
    String _wallertSign = infoConfig['wallet_sign'] ?? '1,2,3';
    walletSigns = _wallertSign.split(',');
  }
}
